package com.netease.financial.module.activitypage;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.netease.financial.module.web.WebViewTabFragment;

import cn.bingoogolapple.badgeview.BGABadgeable;

/**
 * A placeholder fragment containing a simple view.
 */
public class ActivityPageFragment extends WebViewTabFragment {

    private String mActivityPageUrl;

    public ActivityPageFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        handleIntent(getActivity().getIntent());
        View view = super.onCreateView(inflater, container, savedInstanceState);
        return view;
    }

    @Override
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        handleIntent(intent);
        getWebView().clearHistory();
        getWebView().loadUrl(mActivityPageUrl);
    }

    private void handleIntent(Intent intent) {
        mActivityPageUrl = intent.getStringExtra(ActivityPageActivity.INTENT_EXTRA_KEY_PAGE_URL);
    }

    @Override
    public String getInitialPageUrl() {
        return mActivityPageUrl;
    }

    @Override
    public boolean isTabBadgeShouldShow() {
        return false;
    }

    @Override
    public void showBadge(BGABadgeable badgeView) {

    }
}
